<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生就业分析系统</title>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
            color: #333;
            min-height: 100vh;
            padding: 20px;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
        }
        
        header {
            text-align: center;
            padding: 30px 20px;
            color: white;
            animation: fadeIn 1s ease;
        }
        
        header h1 {
            font-size: 2.8rem;
            margin-bottom: 10px;
            text-shadow: 0 2px 5px rgba(0,0,0,0.2);
        }
        
        header p {
            font-size: 1.2rem;
            max-width: 700px;
            margin: 0 auto;
            opacity: 0.9;
        }
        
        .app-container {
            display: flex;
            flex-wrap: wrap;
            gap: 25px;
            margin-top: 20px;
        }
        
        .card {
            background: white;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.15);
            padding: 25px;
            transition: transform 0.3s ease;
        }
        
        .card:hover {
            transform: translateY(-5px);
        }
        
        .input-section {
            flex: 1;
            min-width: 300px;
        }
        
        .stats-section {
            flex: 2;
            min-width: 300px;
        }
        
        .chart-section {
            flex: 100%;
        }
        
        h2 {
            color: #2c3e50;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 2px solid #3498db;
            font-size: 1.8rem;
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 600;
            color: #2c3e50;
        }
        
        input, select {
            width: 100%;
            padding: 12px 15px;
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            font-size: 1rem;
            transition: border-color 0.3s;
        }
        
        input:focus, select:focus {
            border-color: #3498db;
            outline: none;
        }
        
        button {
            background: #3498db;
            color: white;
            border: none;
            padding: 14px 20px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 1.1rem;
            font-weight: 600;
            width: 100%;
            transition: background 0.3s;
            margin-top: 10px;
        }
        
        button:hover {
            background: #2980b9;
        }
        
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }
        
        .stat-card {
            background: linear-gradient(135deg, #3498db 0%, #2c3e50 100%);
            color: white;
            padding: 20px;
            border-radius: 10px;
            text-align: center;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }
        
        .stat-card i {
            font-size: 2.5rem;
            margin-bottom: 15px;
        }
        
        .stat-value {
            font-size: 2.2rem;
            font-weight: 700;
            margin: 10px 0;
        }
        
        .stat-label {
            font-size: 1.1rem;
            opacity: 0.9;
        }
        
        .chart-container {
            height: 400px;
            margin-top: 20px;
            position: relative;
        }
        
        .data-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 25px;
            background: white;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 5px 15px rgba(0,0,0,0.05);
        }
        
        .data-table th {
            background: #3498db;
            color: white;
            text-align: left;
            padding: 15px 20px;
        }
        
        .data-table td {
            padding: 12px 20px;
            border-bottom: 1px solid #eee;
        }
        
        .data-table tr:hover {
            background-color: #f5f9ff;
        }
        
        .footer {
            text-align: center;
            color: white;
            padding: 30px;
            margin-top: 40px;
            font-size: 1.1rem;
            opacity: 0.8;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        @media (max-width: 768px) {
            .app-container {
                flex-direction: column;
            }
            
            header h1 {
                font-size: 2.2rem;
            }
            
            .stat-value {
                font-size: 1.8rem;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1><i class="fas fa-graduation-cap"></i> 学生就业分析系统</h1>
            <p>简洁高效的学生就业数据管理与分析工具</p>
        </header>
        
        <div class="app-container">
            <div class="card input-section">
                <h2><i class="fas fa-user-graduate"></i> 学生信息录入</h2>
                <div class="form-group">
                    <label for="name">学生姓名</label>
                    <input type="text" id="name" placeholder="请输入学生姓名">
                </div>
                <div class="form-group">
                    <label for="major">所学专业</label>
                    <select id="major">
                        <option value="计算机科学">计算机科学</option>
                        <option value="软件工程">软件工程</option>
                        <option value="数据科学">数据科学</option>
                        <option value="人工智能">人工智能</option>
                        <option value="电子信息工程">电子信息工程</option>
                        <option value="其他">其他</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="status">就业状态</label>
                    <select id="status">
                        <option value="已就业">已就业</option>
                        <option value="待就业">待就业</option>
                        <option value="继续深造">继续深造</option>
                        <option value="自主创业">自主创业</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="salary">月薪 (元)</label>
                    <input type="number" id="salary" placeholder="请输入月薪" value="8000">
                </div>
                <div class="form-group">
                    <label for="company">就业单位</label>
                    <input type="text" id="company" placeholder="请输入就业单位名称">
                </div>
                <button id="addBtn"><i class="fas fa-plus-circle"></i> 添加学生记录</button>
            </div>
            
            <div class="card stats-section">
                <h2><i class="fas fa-chart-line"></i> 就业统计分析</h2>
                <div class="stats-grid">
                    <div class="stat-card">
                        <i class="fas fa-users"></i>
                        <div class="stat-value" id="totalStudents">0</div>
                        <div class="stat-label">学生总数</div>
                    </div>
                    <div class="stat-card">
                        <i class="fas fa-briefcase"></i>
                        <div class="stat-value" id="employed">0%</div>
                        <div class="stat-label">就业率</div>
                    </div>
                    <div class="stat-card">
                        <i class="fas fa-money-bill-wave"></i>
                        <div class="stat-value" id="avgSalary">0</div>
                        <div class="stat-label">平均月薪</div>
                    </div>
                    <div class="stat-card">
                        <i class="fas fa-university"></i>
                        <div class="stat-value" id="higherEdu">0%</div>
                        <div class="stat-label">深造率</div>
                    </div>
                </div>
                
                <table class="data-table">
                    <thead>
                        <tr>
                            <th>姓名</th>
                            <th>专业</th>
                            <th>状态</th>
                            <th>月薪</th>
                            <th>单位</th>
                        </tr>
                    </thead>
                    <tbody id="dataTable">
                        <!-- 数据将通过JS动态添加 -->
                    </tbody>
                </table>
            </div>
            
            <div class="card chart-section">
                <h2><i class="fas fa-chart-pie"></i> 就业数据可视化</h2>
                <div class="chart-container">
                    <canvas id="employmentChart"></canvas>
                </div>
            </div>
        </div>
        
        <div class="footer">
            <p>© 2023 学生就业分析系统 | 设计：前端开发 | 数据仅存储在本地浏览器</p>
        </div>
    </div>


    <script>
        // 初始化示例数据
        const sampleData = [
            { name: "张三", major: "计算机科学", status: "已就业", salary: 12000, company: "腾讯科技" },
            { name: "李四", major: "软件工程", status: "已就业", salary: 15000, company: "阿里巴巴" },
            { name: "王五", major: "人工智能", status: "继续深造", salary: 0, company: "清华大学" },
            { name: "赵六", major: "数据科学", status: "已就业", salary: 13000, company: "字节跳动" },
            { name: "钱七", major: "电子信息工程", status: "待就业", salary: 0, company: "" }
        ];
        
        let students = JSON.parse(localStorage.getItem('students')) || sampleData;
        
        // DOM元素
        const addBtn = document.getElementById('addBtn');
        const dataTable = document.getElementById('dataTable');
        const totalStudents = document.getElementById('totalStudents');
        const employed = document.getElementById('employed');
        const avgSalary = document.getElementById('avgSalary');
        const higherEdu = document.getElementById('higherEdu');
        
        // 初始化页面
        function initPage() {
            renderTable();
            updateStats();
            renderCharts();
        }
        
        // 渲染数据表格
        function renderTable() {
            dataTable.innerHTML = '';
            
            students.forEach(student => {
                const row = document.createElement('tr');
                
                row.innerHTML = `
                    <td>${student.name}</td>
                    <td>${student.major}</td>
                    <td>${student.status}</td>
                    <td>${student.salary ? student.salary.toLocaleString() + '元' : '-'}</td>
                    <td>${student.company || '-'}</td>
                `;
                
                dataTable.appendChild(row);
            });
        }
        
        // 更新统计信息
        function updateStats() {
            totalStudents.textContent = students.length;
            
            // 计算就业率
            const employedCount = students.filter(s => s.status === '已就业').length;
            const employedPercentage = Math.round((employedCount / students.length) * 100);
            employed.textContent = `${employedPercentage}%`;
            
            // 计算平均薪资（仅考虑已就业学生）
            const employedStudents = students.filter(s => s.status === '已就业' && s.salary > 0);
            const totalSalary = employedStudents.reduce((sum, student) => sum + student.salary, 0);
            const averageSalary = employedStudents.length > 0 ? Math.round(totalSalary / employedStudents.length) : 0;
            avgSalary.textContent = `${averageSalary.toLocaleString()}元`;
            
            // 计算深造率
            const higherEduCount = students.filter(s => s.status === '继续深造').length;
            const higherEduPercentage = Math.round((higherEduCount / students.length) * 100);
            higherEdu.textContent = `${higherEduPercentage}%`;
        }
        
        // 渲染图表
        function renderCharts() {
            const ctx = document.getElementById('employmentChart').getContext('2d');
            
            // 按状态统计
            const statusCount = {
                '已就业': students.filter(s => s.status === '已就业').length,
                '待就业': students.filter(s => s.status === '待就业').length,
                '继续深造': students.filter(s => s.status === '继续深造').length,
                '自主创业': students.filter(s => s.status === '自主创业').length
            };
            
            // 按专业统计就业人数
            const majors = [...new Set(students.map(s => s.major))];
            const majorData = majors.map(major => 
                students.filter(s => s.major === major && s.status === '已就业').length
            );
            
            // 创建组合图表
            new Chart(ctx, {
                type: 'bar',
                data: {
                    labels: majors,
                    datasets: [{
                        label: '各专业就业人数',
                        data: majorData,
                        backgroundColor: 'rgba(54, 162, 235, 0.7)',
                        borderColor: 'rgba(54, 162, 235, 1)',
                        borderWidth: 1
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    scales: {
                        y: {
                            beginAtZero: true,
                            title: {
                                display: true,
                                text: '就业人数'
                            }
                        },
                        x: {
                            title: {
                                display: true,
                                text: '专业'
                            }
                        }
                    },
                    plugins: {
                        legend: {
                            position: 'top',
                        },
                        title: {
                            display: true,
                            text: '各专业就业人数分布'
                        }
                    }
                }
            });
        }
        
        // 添加新学生
        addBtn.addEventListener('click', () => {
            const name = document.getElementById('name').value;
            const major = document.getElementById('major').value;
            const status = document.getElementById('status').value;
            const salary = parseInt(document.getElementById('salary').value) || 0;
            const company = document.getElementById('company').value;
            
            if (!name) {
                alert('请输入学生姓名');
                return;
            }
            
            const newStudent = {
                name,
                major,
                status,
                salary,
                company
            };
            
            students.push(newStudent);
            localStorage.setItem('students', JSON.stringify(students));
            
            // 重置表单
            document.getElementById('name').value = '';
            document.getElementById('salary').value = '8000';
            document.getElementById('company').value = '';
            
            renderTable();
            updateStats();
            renderCharts();
            
            alert('学生记录添加成功！');
        });
        
        // 初始化页面
        window.onload = initPage;
    </script>
</body>
</html>